package wyp.library.ui.dialog;

import wyp.library.R;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

/**
 * 网络交互时的弹窗
 * 
 * @author wuyiping
 * 
 */
public class WypHttpDialog extends Dialog {

	private static WypHttpDialog dialog;

	/**
	 * 显示弹窗
	 * 
	 * @param __context
	 */
	public static void showDialog(Context __context) {
		if (dialog == null) {
			dialog = new WypHttpDialog(__context);
		} else {
			try {
				WypHttpDialog.closeDialog();
			} catch (Exception e) {
			}
		}
		dialog.show();
	}

	/**
	 * 关闭弹窗
	 */
	public static void closeDialog() {
		try {
			dialog.dismiss();
			dialog = null;
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}

	private WypHttpDialog(Context context) {
		super(context, R.style.custom_dialog);
		setCanceledOnTouchOutside(false);
		setCancelable(false);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.wyp_http_dialog);
	}

}
